package com.jin.webvideo.config.filter.access.rule;

import com.jin.webvideo.config.filter.access.GlobalStore;
import com.jin.webvideo.config.filter.access.handler.AccessHandler;
import com.jin.webvideo.entity.SessionStore;

import javax.servlet.http.HttpServletRequest;

public class AndAccessRule extends MultiAccessRule {
    public AndAccessRule(AccessHandler.AccessRule... rules) {
        super(rules);
    }

    @Override
    public boolean compute(GlobalStore globalStore, SessionStore store, HttpServletRequest request) {
        for (AccessHandler.AccessRule handler : rules) {
            if (!handler.compute(globalStore, store, request)) {
                return false;
            }
        }
        return true;
    }

}
